package cinema.ELTEcinema_ejb.Entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@SuppressWarnings("serial")
@Entity
@Table(name = "TIMETABLE")
public class TimeTable implements Serializable{

	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Id
	@Column(name="TID")
	private int tId;
	
	@ManyToOne
	@JoinColumn(name="MOVIE_MID")
	private Movie movie;
	
	@ManyToOne
	@JoinColumn(name="ROOM_ROOMID")
	private Room room;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="STARTTIME")
	private Date startTime;
	
	@Transient
	private boolean canEdit;
	
	public TimeTable(){}
	
	public TimeTable(Movie movie, Room room, Date startTime){
		this.movie = new Movie(movie);
		this.room = new Room(room);
		this.startTime = startTime;
	}
	
	public TimeTable(TimeTable t) {
		this.movie = new Movie(t.movie);
		this.room = new Room(t.room);
		this.startTime = t.startTime;
	}

	public Movie getMovie(){
		return movie;
	}

	public Room getRoom(){
		return room;
	}

	public Date getStartTime(){
		return startTime;
	}

	public int getTId(){
		return tId;
	}

	public void setMovie(Movie newVal){
		movie = newVal;
	}

	public void setRoom(Room newVal){
		room = newVal;
	}

	public void setStartTime(Date newVal){
		startTime = newVal;
	}

	public void setTId(int newVal){
		tId = newVal;
	}

	public boolean isCanEdit() {
		return canEdit;
	}

	public void setCanEdit(boolean canEdit) {
		this.canEdit = canEdit;
	}
}